Cholesky_decomposition Subroutine

public subroutine Cholesky_decomposition(A, L)

Cholesky decomposition of a matrix A This subroutine performs Cholesky decomposition of a given symmetric positive definite matrix A, where L is a lower triangular matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in), DIMENSION(: ,:) :: A
real(kind=dp), intent(out), DIMENSION(SIZE(A, 1), SIZE(A, 1)) :: L

Source Code

    SUBROUTINE Cholesky_decomposition(A, L)

        REAL(dp),DIMENSION(: ,:), INTENT(IN) :: A
        REAL(dp),DIMENSION(SIZE(A, 1), SIZE(A, 1)), INTENT(OUT) :: L
        INTEGER :: i, j, N

        N = SIZE(A, 1)

        DO j = 1, N
            L(j, j) = SQRT(A(j, j) - DOT_PRODUCT(L(j, 1:j-1), L(j, 1:j-1)))

            DO i = j+1, N
                L(i, j) = (A(i, j) - DOT_PRODUCT(L(i, 1:j-1), L(j, 1:j-1))) / L(j, j)
            END DO
        END DO

    END SUBROUTINE Cholesky_decomposition